$(function() {
	var word = localStorage.getItem("Indiana_word");
	console.log(word);
	$.ajax({
			type: "post",
			url: "http://a.91jfk.com/Product/Indiana/search_index",
			async: true,
			data: {
				platform: 1,
				pname: word
			},
			dataType: 'json',
			success: function(res) {
				console.log(res);
				if(res.code == "1") {
					var data = res.msg;
					for(var i = 0; i < data.length; i++) {
						showItem(data[i].thumbnail, data[i].pname, data[i].price, data[i].id);
					}
				}
		},
		error: function(err) {
			console.log(err);
		}
	});

//展示商品
function showItem(img, name, price, id) {
	var shop_list = $(".popularity_box");
	var shop_one = $('<div class="shop_one"><img style="width: 3.32rem;margin-top: 0.666666rem;margin-left: 0.52rem;" src= "' + img + '"/><p class="name">' + name + '</p><p class="immediately">立即夺宝<span style="display:none">&yen;' + price + '集分</span></p><p class="id" style = "display:none">' + id + '</p></div>');
	shop_list.append(shop_one);
}


	//点击每个商品进入详情页
	$(".popularity_box").on("click", ".shop_one", function() {
		var id = $(this).find(".id").text();
		window.location.href = "page_dbDetail.html?id=" + id;
	});
});